<html>
<head>
	<meta charset="UTF-8">
	<meta content="IE=edge" http-equiv="X-UA-Compatible">
	<meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" name="viewport">
	<title>2321：[BeiJing2011集训]星器</title>
	<!-- css -->
	<link href="../css/base.min.css" rel="stylesheet">
	<link href="../css/project.min.css" rel="stylesheet">
	
	<!-- favicon -->
	<!-- ... -->
</head>
<body class="page-brand">
	<header class="header header-transparent header-waterfall ui-header">
		<ul class="nav nav-list pull-left">
			<li>
				<a data-toggle="menu" href="#menu">
					<span class="icon icon-lg">menu</span>
				</a>
			</li>
		</ul>
		<a class="header-logo header-affix-hide margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[BeiJing2011集训]星器</a>
		<span class="header-logo header-affix margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[BeiJing2011集训]星器</span>
	</header>
	<nav aria-hidden="true" class="menu" id="menu" tabindex="-1">
		<div class="menu-scroll">
			<div class="menu-content">
				<a class="menu-logo" href="../index.html">BZOJ离线题库</a>
				<ul class="nav">
					<li>
						<a class="waves-attach" data-toggle="collapse" href="#problems">题目</a>
						<ul class="menu-collapse collapse in" id="problems">
							<li>
								<a class="waves-attach" href="../index.html">主页</a>
							</li>
							<li>
								<a class="waves-attach" href="../list.html">题目列表</a>
							</li>
						</ul>
					</li>
					<li>
						<a class="collapsed waves-attach" data-toggle="collapse" href="#about">关于</a>
						<ul class="menu-collapse collapse" id="about">
							<li>
								<a class="waves-attach" href="../about.html">关于此项目</a>
							</li>
						</ul>
					</li>
					
				</ul>
			</div>
		</div>
	</nav>
	<main class="content">
		<div class="content-header ui-content-header">
			<div class="container">
				<h1 class="content-heading">
                [BeiJing2011集训]星器                </h1>
                <p>时间限制：1s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  空间限制：128MB</p>			</div>
		</div>
		<div class="container">
			<section class="content-inner margin-top-no">
				<div class="row">
					<div class="col-lg-13 col-md-13">
						<div class="card margin-bottom-no">
							<div class="card-main">
								<div class="card-inner">
									
                                <h3>题目描述</h3><p><h2 style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 12pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></h2>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Magic&nbsp;Land</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">上的时间又过了若干世纪&hellip;&hellip;</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">现在，人们谈论着一个传说：从前，他们的祖先来到了一个位于东方的岛屿，那里简直就是另外一个世界。善于分析与构造的</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Magic&nbsp;Land</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">上的人们总是不明白那里的人们是如何不借助精确的实验与计算驱动和操纵魔法。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">偶然地，一个魔法使（</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Magician</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">）来到了</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Magic&nbsp;Land</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">，在临走的时候留下了一个神奇的盒子，叫做</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">星器</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">（</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Casket&nbsp;of&nbsp;star</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">）。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">虽然不知道这个盒子是做什么的，但是经过了大量的实验和计算后，人们已经清楚它的一些事实：</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">1<font face="宋体">．</font></span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">星器</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">之中有</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">N<font face="宋体">&times;</font><font face="Times New Roman">M</font></span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">个区域，可看作分成</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">行和</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">M</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">列的格子，每个区域之中有若干单位的称为&ldquo;星&rdquo;的对象，这个对象的最小单位已经被确定，所以，这个数量总是整数。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">2<font face="宋体">．魔法使可以驱动</font></span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">星器</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">中位于</span><span style="font-weight: bold; font-size: 12pt; font-family: '宋体'; text-decoration: underline; mso-spacerun: 'yes'">同一行或同一列</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">的</span><span style="font-weight: bold; font-size: 12pt; font-family: '宋体'; text-decoration: underline; mso-spacerun: 'yes'">不相邻</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">（有公共边的区域称为相邻的）两个区域中各<font face="Times New Roman">1</font><font face="宋体">单位的&ldquo;星&rdquo;，使得它们</font></span><span style="font-weight: bold; font-size: 12pt; font-family: '宋体'; text-decoration: underline; mso-spacerun: 'yes'">分别向中心移动<font face="Times New Roman">1</font><font face="宋体">格</font></span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">3<font face="宋体">．每一次使用</font><font face="Times New Roman">2</font><font face="宋体">中的方法驱动&ldquo;星&rdquo;，将会产生魔力，魔法使会得到这一部分魔力。</font></span><span style="font-weight: bold; font-size: 12pt; font-family: '宋体'; text-decoration: underline; mso-spacerun: 'yes'">魔力的量等于这个两个区域之间所间隔的区域数</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">这样，我们可以用一个</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">N<font face="宋体">&times;</font><font face="Times New Roman">M</font></span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">的数表来表示</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">星器</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">的状态，比如</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">N=2</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">，</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">M=3</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">时：</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p>
<table align="center" style="padding-right: 5.4pt; padding-left: 5.4pt; padding-bottom: 0pt; padding-top: 0pt; border-collapse: collapse; mso-table-layout-alt: fixed">
    <tbody>
        <tr style="height: 14.8pt">
            <td valign="top" width="48" style="border-right: rgb(0,0,0) 0.5pt solid; padding-right: 5.4pt; border-top: rgb(0,0,0) 0.5pt solid; padding-left: 5.4pt; padding-bottom: 0pt; border-left: rgb(0,0,0) 0.5pt solid; width: 36.7pt; padding-top: 0pt; border-bottom: rgb(0,0,0) 0.5pt solid; mso-border-bottom-alt: 0.5000pt solid rgb(0,0,0); mso-border-left-alt: 0.5000pt solid rgb(0,0,0); mso-border-right-alt: 0.5000pt solid rgb(0,0,0); mso-border-top-alt: 0.5000pt solid rgb(0,0,0)">
            <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: center"><span style="font-weight: bold; font-size: 12pt; font-family: '宋体'; text-decoration: underline">2</span><span style="font-weight: bold; font-size: 12pt; font-family: 'Times New Roman'; text-decoration: underline"><o:p></o:p></span></p>
            </td>
            <td valign="top" width="48" style="border-right: rgb(0,0,0) 0.5pt solid; padding-right: 5.4pt; border-top: rgb(0,0,0) 0.5pt solid; padding-left: 5.4pt; padding-bottom: 0pt; border-left: medium none; width: 36.7pt; padding-top: 0pt; border-bottom: rgb(0,0,0) 0.5pt solid; mso-border-bottom-alt: 0.5000pt solid rgb(0,0,0); mso-border-left-alt: none; mso-border-right-alt: 0.5000pt solid rgb(0,0,0); mso-border-top-alt: 0.5000pt solid rgb(0,0,0)">
            <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: center"><span style="font-size: 12pt; font-family: '宋体'">0</span><span style="font-size: 12pt; font-family: 'Times New Roman'"><o:p></o:p></span></p>
            </td>
            <td valign="top" width="48" style="border-right: rgb(0,0,0) 0.5pt solid; padding-right: 5.4pt; border-top: rgb(0,0,0) 0.5pt solid; padding-left: 5.4pt; padding-bottom: 0pt; border-left: medium none; width: 36.7pt; padding-top: 0pt; border-bottom: rgb(0,0,0) 0.5pt solid; mso-border-bottom-alt: 0.5000pt solid rgb(0,0,0); mso-border-left-alt: none; mso-border-right-alt: 0.5000pt solid rgb(0,0,0); mso-border-top-alt: 0.5000pt solid rgb(0,0,0)">
            <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: center"><span style="font-weight: bold; font-size: 12pt; font-family: '宋体'; text-decoration: underline">1</span><span style="font-weight: bold; font-size: 12pt; font-family: 'Times New Roman'; text-decoration: underline"><o:p></o:p></span></p>
            </td>
            <td valign="top" width="48" style="border-right: rgb(255,255,255) 31.875pt; padding-right: 5.4pt; border-top: rgb(255,255,255) 31.875pt; padding-left: 5.4pt; padding-bottom: 0pt; border-left: medium none; width: 36.7pt; padding-top: 0pt; border-bottom: rgb(255,255,255) 31.875pt; mso-border-bottom-alt: 31.8750pt none rgb(255,255,255); mso-border-left-alt: none; mso-border-right-alt: 31.8750pt none rgb(255,255,255); mso-border-top-alt: 31.8750pt none rgb(255,255,255)">
            <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: center"><span style="font-size: 12pt; font-family: 'Times New Roman'"><o:p></o:p></span></p>
            </td>
            <td valign="top" width="48" style="border-right: rgb(0,0,0) 0.5pt solid; padding-right: 5.4pt; border-top: rgb(255,255,255) 31.875pt; padding-left: 5.4pt; padding-bottom: 0pt; border-left: medium none; width: 36.7pt; padding-top: 0pt; border-bottom: rgb(255,255,255) 31.875pt; mso-border-bottom-alt: 31.8750pt none rgb(255,255,255); mso-border-left-alt: none; mso-border-right-alt: 0.5000pt solid rgb(0,0,0); mso-border-top-alt: 31.8750pt none rgb(255,255,255)">
            <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: center"><span style="font-size: 12pt; font-family: 'Times New Roman'"><o:p></o:p></span></p>
            </td>
            <td valign="top" width="48" style="border-right: rgb(0,0,0) 0.5pt solid; padding-right: 5.4pt; border-top: rgb(0,0,0) 0.5pt solid; padding-left: 5.4pt; padding-bottom: 0pt; border-left: medium none; width: 36.7pt; padding-top: 0pt; border-bottom: rgb(0,0,0) 0.5pt solid; mso-border-bottom-alt: 0.5000pt solid rgb(0,0,0); mso-border-left-alt: none; mso-border-right-alt: 0.5000pt solid rgb(0,0,0); mso-border-top-alt: 0.5000pt solid rgb(0,0,0)">
            <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: center"><span style="font-size: 12pt; font-family: '宋体'">1</span><span style="font-size: 12pt; font-family: 'Times New Roman'"><o:p></o:p></span></p>
            </td>
            <td valign="top" width="49" style="border-right: rgb(0,0,0) 0.5pt solid; padding-right: 5.4pt; border-top: rgb(0,0,0) 0.5pt solid; padding-left: 5.4pt; padding-bottom: 0pt; border-left: medium none; width: 36.75pt; padding-top: 0pt; border-bottom: rgb(0,0,0) 0.5pt solid; mso-border-bottom-alt: 0.5000pt solid rgb(0,0,0); mso-border-left-alt: none; mso-border-right-alt: 0.5000pt solid rgb(0,0,0); mso-border-top-alt: 0.5000pt solid rgb(0,0,0)">
            <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: center"><span style="font-weight: bold; font-size: 12pt; font-family: '宋体'; text-decoration: underline">2</span><span style="font-weight: bold; font-size: 12pt; font-family: 'Times New Roman'; text-decoration: underline"><o:p></o:p></span></p>
            </td>
            <td valign="top" width="49" style="border-right: rgb(0,0,0) 0.5pt solid; padding-right: 5.4pt; border-top: rgb(0,0,0) 0.5pt solid; padding-left: 5.4pt; padding-bottom: 0pt; border-left: medium none; width: 36.75pt; padding-top: 0pt; border-bottom: rgb(0,0,0) 0.5pt solid; mso-border-bottom-alt: 0.5000pt solid rgb(0,0,0); mso-border-left-alt: none; mso-border-right-alt: 0.5000pt solid rgb(0,0,0); mso-border-top-alt: 0.5000pt solid rgb(0,0,0)">
            <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: center"><span style="font-size: 12pt; font-family: '宋体'">0</span><span style="font-size: 12pt; font-family: 'Times New Roman'"><o:p></o:p></span></p>
            </td>
        </tr>
        <tr style="height: 16.15pt">
            <td valign="top" width="48" style="border-right: rgb(0,0,0) 0.5pt solid; padding-right: 5.4pt; border-top: medium none; padding-left: 5.4pt; padding-bottom: 0pt; border-left: rgb(0,0,0) 0.5pt solid; width: 36.7pt; padding-top: 0pt; border-bottom: rgb(0,0,0) 0.5pt solid; mso-border-bottom-alt: 0.5000pt solid rgb(0,0,0); mso-border-left-alt: 0.5000pt solid rgb(0,0,0); mso-border-right-alt: 0.5000pt solid rgb(0,0,0); mso-border-top-alt: 0.5000pt solid rgb(0,0,0)">
            <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: center"><span style="font-size: 12pt; font-family: '宋体'">5</span><span style="font-size: 12pt; font-family: 'Times New Roman'"><o:p></o:p></span></p>
            </td>
            <td valign="top" width="48" style="border-right: rgb(0,0,0) 0.5pt solid; padding-right: 5.4pt; border-top: medium none; padding-left: 5.4pt; padding-bottom: 0pt; border-left: medium none; width: 36.7pt; padding-top: 0pt; border-bottom: rgb(0,0,0) 0.5pt solid; mso-border-bottom-alt: 0.5000pt solid rgb(0,0,0); mso-border-left-alt: none; mso-border-right-alt: 0.5000pt solid rgb(0,0,0); mso-border-top-alt: 0.5000pt solid rgb(0,0,0)">
            <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: center"><span style="font-size: 12pt; font-family: '宋体'">1</span><span style="font-size: 12pt; font-family: 'Times New Roman'"><o:p></o:p></span></p>
            </td>
            <td valign="top" width="48" style="border-right: rgb(0,0,0) 0.5pt solid; padding-right: 5.4pt; border-top: medium none; padding-left: 5.4pt; padding-bottom: 0pt; border-left: medium none; width: 36.7pt; padding-top: 0pt; border-bottom: rgb(0,0,0) 0.5pt solid; mso-border-bottom-alt: 0.5000pt solid rgb(0,0,0); mso-border-left-alt: none; mso-border-right-alt: 0.5000pt solid rgb(0,0,0); mso-border-top-alt: 0.5000pt solid rgb(0,0,0)">
            <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: center"><span style="font-size: 12pt; font-family: '宋体'">4</span><span style="font-size: 12pt; font-family: 'Times New Roman'"><o:p></o:p></span></p>
            </td>
            <td valign="top" width="48" style="border-right: rgb(255,255,255) 31.875pt; padding-right: 5.4pt; border-top: medium none; padding-left: 5.4pt; padding-bottom: 0pt; border-left: medium none; width: 36.7pt; padding-top: 0pt; border-bottom: rgb(255,255,255) 31.875pt; mso-border-bottom-alt: 31.8750pt none rgb(255,255,255); mso-border-left-alt: none; mso-border-right-alt: 31.8750pt none rgb(255,255,255); mso-border-top-alt: 31.8750pt none rgb(255,255,255)">
            <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: center"><span style="font-size: 12pt; font-family: 'Times New Roman'"><o:p></o:p></span></p>
            </td>
            <td valign="top" width="48" style="border-right: rgb(0,0,0) 0.5pt solid; padding-right: 5.4pt; border-top: medium none; padding-left: 5.4pt; padding-bottom: 0pt; border-left: medium none; width: 36.7pt; padding-top: 0pt; border-bottom: rgb(255,255,255) 31.875pt; mso-border-bottom-alt: 31.8750pt none rgb(255,255,255); mso-border-left-alt: none; mso-border-right-alt: 0.5000pt solid rgb(0,0,0); mso-border-top-alt: 31.8750pt none rgb(255,255,255)">
            <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: center"><span style="font-size: 12pt; font-family: 'Times New Roman'"><o:p></o:p></span></p>
            </td>
            <td valign="top" width="48" style="border-right: rgb(0,0,0) 0.5pt solid; padding-right: 5.4pt; border-top: medium none; padding-left: 5.4pt; padding-bottom: 0pt; border-left: medium none; width: 36.7pt; padding-top: 0pt; border-bottom: rgb(0,0,0) 0.5pt solid; mso-border-bottom-alt: 0.5000pt solid rgb(0,0,0); mso-border-left-alt: none; mso-border-right-alt: 0.5000pt solid rgb(0,0,0); mso-border-top-alt: 0.5000pt solid rgb(0,0,0)">
            <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: center"><span style="font-size: 12pt; font-family: '宋体'">5</span><span style="font-size: 12pt; font-family: 'Times New Roman'"><o:p></o:p></span></p>
            </td>
            <td valign="top" width="49" style="border-right: rgb(0,0,0) 0.5pt solid; padding-right: 5.4pt; border-top: medium none; padding-left: 5.4pt; padding-bottom: 0pt; border-left: medium none; width: 36.75pt; padding-top: 0pt; border-bottom: rgb(0,0,0) 0.5pt solid; mso-border-bottom-alt: 0.5000pt solid rgb(0,0,0); mso-border-left-alt: none; mso-border-right-alt: 0.5000pt solid rgb(0,0,0); mso-border-top-alt: 0.5000pt solid rgb(0,0,0)">
            <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: center"><span style="font-size: 12pt; font-family: '宋体'">1</span><span style="font-size: 12pt; font-family: 'Times New Roman'"><o:p></o:p></span></p>
            </td>
            <td valign="top" width="49" style="border-right: rgb(0,0,0) 0.5pt solid; padding-right: 5.4pt; border-top: medium none; padding-left: 5.4pt; padding-bottom: 0pt; border-left: medium none; width: 36.75pt; padding-top: 0pt; border-bottom: rgb(0,0,0) 0.5pt solid; mso-border-bottom-alt: 0.5000pt solid rgb(0,0,0); mso-border-left-alt: none; mso-border-right-alt: 0.5000pt solid rgb(0,0,0); mso-border-top-alt: 0.5000pt solid rgb(0,0,0)">
            <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: center"><span style="font-size: 12pt; font-family: '宋体'">4</span><span style="font-size: 12pt; font-family: 'Times New Roman'"><o:p></o:p></span></p>
            </td>
        </tr>
    </tbody>
</table>
</p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt; text-align: left"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">当</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">星器</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">为左图的状态时，通过操纵第一行的第<font face="Times New Roman">1</font><font face="宋体">和</font><font face="Times New Roman">3</font><font face="宋体">个区域中的&ldquo;星&rdquo;（加粗的数字对应的区域），变为右图所示的状态，同时，将产生</font><font face="Times New Roman">1</font><font face="宋体">单位的魔力（因为这两个区域之间恰好隔了</font><font face="Times New Roman">1</font><font face="宋体">个区域）。</font></span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">在经过了进一步的研究之后，人们知道了这个</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">星器</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">最初的状态（</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Ini</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">）以及最终被他们得到时的状态（</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Fin</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">）。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">你希望知道，</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">星器</span><span style="font-weight: bold; font-size: 12pt; font-family: '宋体'; text-decoration: underline; mso-spacerun: 'yes'">最多</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">帮助它的拥有者提供了多少的魔力。即：经过一系列上述操作由初态（</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Ini</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">）变为终态（</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Fin</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">），至多产生多少魔力。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">需要注意的是，显然操作过程中每个区域内&ldquo;星&rdquo;的数量</span><span style="font-weight: bold; font-size: 12pt; font-family: '宋体'; text-decoration: underline; mso-spacerun: 'yes'">不能是负的</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">，即：如果那个区域已经没有&ldquo;星&rdquo;了，当然就不能继续操作了。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<!--EndFragment--></p><hr/><h3>输入格式</h3><p><p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">第一行</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">包含两个正</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">整数</span><span style="font-size: 12pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">N</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">、</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">M</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">表示</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">星器</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">的大小</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">接下来的</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">行，每行包含</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">M</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">个自然数：</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Ini</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">ij</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">，描绘了初态（</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Ini</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">）。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">在一个空行后的</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">行，每行包含</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">M</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">个自然数：</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Fin</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">ij</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">，描绘了终态（</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Fin</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">）。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p></p><hr/><h3>输出格式</h3><p><p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">输出一个正整数，表示至多产生的魔力。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<h2 style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></h2></p><hr/><h3>样例输入</h3><pre>【输入样例1】
5 5

1 0 0 0 1

0 0 0 0 0

0 0 0 0 0

0 1 0 1 1

1 0 0 0 0


0 0 0 0 0

0 0 0 0 1

2 0 0 0 1

0 0 2 0 0

0 0 0 0 0



【输入样例2】
1 4

10 20 30 40


0 0 100 0

</pre><hr/><h3>样例输出</h3><pre>【输出样例1】
7

【样例1解释】
唯一的一种操作方法是：

对第5列的两个“星”进行一次操作，产生魔力2；

对第1列的两个“星”进行两次操作，产生魔力3+1；

对第4行的两个“星”进行一次操作，产生魔力1；

一共产生7单位的魔力。

【输出样例2】
50


</pre><hr/><h3>提示</h3><p><p>【数据规模和约定】<br />
40%的数据中N &le; 2，如样例2；</p>
<p>100%的数据中1 &le; N，M &le; 200，Iniij，Finij &le; 1000。</p>
<p>所有数据保证了至少存在一个操作方法使得星器由初态变为终态，同时保证了初态与终态不是完全相同的。</p>
<p></p></p><hr/><h3>题目来源</h3><p>没有写明来源</p>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				
			</section>
		</div>
	</main>

	<div class="fbtn-container">
		<div class="fbtn-inner">
			<a class="fbtn fbtn-lg fbtn-brand-accent waves-attach waves-circle waves-light waves-effect" data-toggle="dropdown" aria-expanded="true"><span class="fbtn-text fbtn-text-left">Menu</span><span class="fbtn-ori icon">apps</span><span class="fbtn-sub icon">close</span></a>
			<div class="fbtn-dropup">
				<a class="fbtn fbtn-brand waves-attach waves-circle waves-light waves-effect" href="../list.html" target="_self"><span class="fbtn-text fbtn-text-left">题目列表</span><span class="icon">menu</span></a>
				<a class="fbtn fbtn-green waves-attach waves-circle waves-effect" href="../index.html" target="_self"><span class="fbtn-text fbtn-text-left">返回主页</span><span class="icon">home</span></a>
				<a class="fbtn waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=2321" target="_blank"><span class="fbtn-text fbtn-text-left">提交代码</span><span class="icon">send</span></a>
				<a class="fbtn fbtn-orange waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/wttl/wttl.php?pid=2321" target="_blank"><span class="fbtn-text fbtn-text-left">试题讨论</span><span class="icon">chat</span></a>
				
			</div>
		</div>
	</div>

	<!-- js -->
	<script src="../js/jquery.min.js"></script>
	<script src="../js/base.min.js"></script>
	<script src="../js/project.min.js"></script>
</body>
</html>